package com.group4.datafactorybackend.entity.DO;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;

/**
 * @author 卑微小峰
 * @date 2022/8/13
 * @description 接口表实体
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value ="api")
public class ApiDO implements Serializable {

    /**
     * 表ID
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 接口编号
     */
    @TableField("api_code")
    private String apiCode;

    /**
     * 接口名称
     */
    @TableField("api_name")
    private String apiName;

    /**
     * 接口描述
     */
    @TableField("api_describe")
    private String apiDescribe;

    /**
     * 接口目录编号
     */
    @TableField("api_directory_code")
    private String apiDirectoryCode;

    /**
     * 接口来源
     */
    @TableField("api_source")
    private String apiSource;

    /**
     * 接口状态
     */
    @TableField("api_status")
    private Integer apiStatus;

    /**
     * 接口协议
     */
    @TableField("api_agreement")
    private String apiAgreement;

    /**
     * 接口IP:端口
     */
    @TableField("api_ip_port")
    private String apiIpPort;

    /**
     * 接口路径
     */
    @TableField("api_path")
    private String apiPath;

    /**
     * 接口请求方式
     */
    @TableField("api_request_method")
    private Integer apiRequestMethod;

    /**
     * 接口请求超时时间
     */
    @TableField("api_request_timeout")
    private String apiRequestTimeout;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private Date createTime;

    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time",fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        ApiDO other = (ApiDO) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getApiCode() == null ? other.getApiCode() == null : this.getApiCode().equals(other.getApiCode()))
            && (this.getApiName() == null ? other.getApiName() == null : this.getApiName().equals(other.getApiName()))
            && (this.getApiDescribe() == null ? other.getApiDescribe() == null : this.getApiDescribe().equals(other.getApiDescribe()))
            && (this.getApiDirectoryCode() == null ? other.getApiDirectoryCode() == null : this.getApiDirectoryCode().equals(other.getApiDirectoryCode()))
            && (this.getApiSource() == null ? other.getApiSource() == null : this.getApiSource().equals(other.getApiSource()))
            && (this.getApiStatus() == null ? other.getApiStatus() == null : this.getApiStatus().equals(other.getApiStatus()))
            && (this.getApiAgreement() == null ? other.getApiAgreement() == null : this.getApiAgreement().equals(other.getApiAgreement()))
            && (this.getApiIpPort() == null ? other.getApiIpPort() == null : this.getApiIpPort().equals(other.getApiIpPort()))
            && (this.getApiPath() == null ? other.getApiPath() == null : this.getApiPath().equals(other.getApiPath()))
            && (this.getApiRequestMethod() == null ? other.getApiRequestMethod() == null : this.getApiRequestMethod().equals(other.getApiRequestMethod()))
            && (this.getApiRequestTimeout() == null ? other.getApiRequestTimeout() == null : this.getApiRequestTimeout().equals(other.getApiRequestTimeout()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getApiCode() == null) ? 0 : getApiCode().hashCode());
        result = prime * result + ((getApiName() == null) ? 0 : getApiName().hashCode());
        result = prime * result + ((getApiDescribe() == null) ? 0 : getApiDescribe().hashCode());
        result = prime * result + ((getApiDirectoryCode() == null) ? 0 : getApiDirectoryCode().hashCode());
        result = prime * result + ((getApiSource() == null) ? 0 : getApiSource().hashCode());
        result = prime * result + ((getApiStatus() == null) ? 0 : getApiStatus().hashCode());
        result = prime * result + ((getApiAgreement() == null) ? 0 : getApiAgreement().hashCode());
        result = prime * result + ((getApiIpPort() == null) ? 0 : getApiIpPort().hashCode());
        result = prime * result + ((getApiPath() == null) ? 0 : getApiPath().hashCode());
        result = prime * result + ((getApiRequestMethod() == null) ? 0 : getApiRequestMethod().hashCode());
        result = prime * result + ((getApiRequestTimeout() == null) ? 0 : getApiRequestTimeout().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", apiCode=").append(apiCode);
        sb.append(", apiName=").append(apiName);
        sb.append(", apiDescribe=").append(apiDescribe);
        sb.append(", apiCatalogCode=").append(apiDirectoryCode);
        sb.append(", apiSource=").append(apiSource);
        sb.append(", apiStatus=").append(apiStatus);
        sb.append(", apiAgreement=").append(apiAgreement);
        sb.append(", apiIpPort=").append(apiIpPort);
        sb.append(", apiPath=").append(apiPath);
        sb.append(", apiRequestMethod=").append(apiRequestMethod);
        sb.append(", apiRequestTimeout=").append(apiRequestTimeout);
        sb.append(", createTime=").append(createTime);
        sb.append(", updateTime=").append(updateTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}